package newnes.io.mappers;

import newnes.io.memory.*;
import java.nio.*;

public class MMC3Mapper extends MappedMemory {
	private Ram registry;
	
	private int prgMode;
	private int chrMode;
		
	public MMC3Mapper(){
		super(0x9000);
		addMemoryHook(registry, new AddressSpace(0x8001, 0x8001));
	}
	
	public int writeToMemory(int address, byte value) {
		Memory hook	= getMemoryHook(address);
		if(hook == registry){
			byte location = (byte)(getMemoryBuffer().get(0x1000)&0x7);
			return registry.writeToMemory(location, value);
		}else{
			ByteBuffer memory_buffer = getMemoryBuffer();
			if(address > 0x1000){
				address -= 0x7000;
			}
			if(address == 0x1000){
				chrMode = (value >> 7)&0x1;
				prgMode = (value >> 6)&0x1;
			}
			memory_buffer.put(address, value);
			return 1;
		}
	}


	public int readFromMemory(int address) throws IndexOutOfBoundsException {
		return 0;
	}	
}
